﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Admin.Admin
{
    public class BasePage : System.Web.UI.Page,System.Web.SessionState.IRequiresSessionState
    {
        

        /// <summary>
        /// 获取用户是否登录
        /// </summary>
        public bool isLogin
        {
            get { return GetAdminLogin(); }
        }

        /// <summary>
        /// 判断是否登录
        /// </summary>
        public void IsLogin()
        {
            if (!isLogin)
            {
                Response.Redirect(System.Configuration.ConfigurationManager.AppSettings.Get("AdminLoginPath"), false);
            }
        }

        /// <summary>
        /// 是否超级管理员
        /// </summary>
        public bool isSuperAdmin
        {
            get { return GetSuperAdmin(); }
        }

        #region 判断是否超级管理员
        private bool GetSuperAdmin()
        {
            int adminId = Convert.ToInt32(Session["AdminID"]);
                return true;
        }
        #endregion
        /// <summary>
        /// 验证页面传递的参数是否为空或者不存在,存在且不为空返回True
        /// </summary>
        /// <param name="requestname"></param>
        /// <returns></returns>
        public bool CheckRequest(string requestname)
        {
            if (Request[requestname] != null && Request[requestname].ToString() != "")
                return true;
            else
                return false;
        }


        #region 检验管理员是否登录了
        private bool GetAdminLogin()
        {
            Session.Timeout = 1440;
            if (Session["AdminID"] != null && Convert.ToInt32(Session["UserID"]) > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        #endregion
    }
}